package com.team.book.common.util;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author iw
 * @create 2017-05-08 16:48
 **/
public class DateUtil {
    public static String DEFAULT_FORMAT = "yyyy-MM-dd HH:mm:ss";
    public static String MS_FORMAT = "yyyyMMddHHmmssSSS";

    public static Date curDate(){
        return new Date();
    }

    /**
     * 获取时间格式到毫秒
     * @return
     */
    public static String curMs(){
        return format(curDate(),MS_FORMAT);
    }

    /**
     * 格式化时间
     * @param date
     * @param format
     * @return
     */
    public static String format(Date date,String format) {
        SimpleDateFormat formatter = new SimpleDateFormat(format);
        return formatter.format(date);
    }
}
